---
id: running-tracetest-with-honeycomb
title: Node.js and Honeycomb
description: Quick start how to configure the OpenTelemetry Demo to use Tracetest for enhancing your E2E and integration tests with trace-based testing with Honeycomb as a trace data store.
hide_table_of_contents: false
keywords:
  - tracetest
  - trace-based testing
  - observability
  - distributed tracing
  - testing
  - honeycomb
  - honeycomb observability
  - testing nodejs
  - nodejs observability
  - honeycomb tracing
  - opentelemetry
image: https://res.cloudinary.com/djwdcmwdz/image/upload/v1698686403/docs/Blog_Thumbnail_14_rsvkmo.jpg
---

:::note
[Check out the source code on GitHub here.](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-honeycomb)
:::

[Tracetest](https://tracetest.io/) is a testing tool based on [OpenTelemetry](https://opentelemetry.io/) that allows you to test your distributed application. It allows you to use data from distributed traces generated by OpenTelemetry to validate and assert if your application has the desired behavior defined by your test definitions.

[Honeycomb](https://honeycomb.io/) is an observability solution that shows you the patterns and outliers of how users experience your code in complex and unpredictable environments.

## Node.js App with Honeycomb, OpenTelemetry and Tracetest

This is a quick start on how to configure a Node.js app to use OpenTelemetry instrumentation with traces, and Tracetest for enhancing your E2E and integration tests with trace-based testing and Honeycomb as a trace data store.

## Prerequisites

**Tracetest Account**:

- Sign up to [`app.tracetest.io`](https://app.tracetest.io) or follow the [get started](/getting-started/overview) docs.
- Have access to the environment's [agent API key](https://app.tracetest.io/retrieve-token).

**Docker**: Have [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine.

## Run This Quckstart Example

The example below is provided as part of the Tracetest project. You can download and run the example by following these steps:

Clone the Tracetest project and go to the Node.js Quickstart:

```bash
git clone https://github.com/kubeshop/tracetest
cd tracetest/examples/tracetest-honeycomb
```

Follow these instructions to run the quick start:

1. Copy the `.env.template` file to `.env`.
2. Fill out the [TRACETEST_TOKEN and ENVIRONMENT_ID](https://app.tracetest.io/retrieve-token) details by editing your `.env` file.
3. Fill out the [HONEYCOMB_API_KEY](https://www.honeycomb.io/) details by editing your `.env` file.
4. Run `docker compose run tracetest-run`.
5. Follow the links in the output to view the test results.

Follow along with the sections below for a detailed breakdown of what the example you just ran did and how it works.

## Project Structure

The quick start Node.js project is built with Docker Compose and contains the Tracetest Agent and a Node.js app.

The `docker-compose.agent.yaml` file in the root directory of the quick start runs the Node.js app and the [Tracetest Agent](/concepts/agent) setup.

## Configuring the Node.js App

The Node.js app is a simple Express app, contained in the `app.js` file.

Configure the `.env` like shown below.

```bash
# Get the required information here: https://app.tracetest.io/retrieve-token

TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>"
TRACETEST_ENVIRONMENT_ID="<YOUR_TRACETEST_ENVIRONMENT_ID>"

HONEYCOMB_API_KEY="<YOUR_HONEYCOMB_API_KEY>"
```

The OpenTelemetry tracing is contained in the `tracing.otel.grpc.js` or `tracing.otel.http.js` files. Traces will be sent to Tracetest Agent.

Choosing [the `tracing.otel.grpc.js` file](https://github.com/kubeshop/tracetest/blob/main/examples/tracetest-honeycomb/tracing.otel.grpc.js) will send traces to Tracetest Agent's `GRPC` endpoint.

Enabling the tracer is done by preloading the trace file. As seen in the `package.json`.

```json
"scripts": {
  "app-with-grpc-tracer": "node -r ./tracing.otel.grpc.js app.js",
},
```

## Run the Node.js App and Tracetest

To execute the tests, run this command:

```bash
docker compose run tracetest-run
```

This will:
1. Start the Node.js app, the OpenTelemetry Collector, and send the traces to Honeycomb.
2. Start the Tracetest Agent.
3. Configure the tracing backend and create tests in your environment.
4. Run the tests.

The output of the test will look similar to this:

```bash
Configuring Tracetest
 SUCCESS  Successfully configured Tracetest CLI
Running Trace-Based Tests...
✘ RunGroup: #VnMxUljSg (https://app.tracetest.io/organizations/xxx/environments/xxx/run/VnMxUljSg)
 Summary: 0 passed, 1 failed, 0 pending
  ✘ Test API (https://app.tracetest.io/organizations/xxx/environments/xxx/test/W656Q0c4g/run/1/test) - trace id: 9d33bbecf956d66b3b277d12e9ca4d3c
	✘ span[tracetest.span.type="http" name="GET /" http.target="/" http.method="GET"]
		✘ #94880e7cd465bd33
			✔ attr:http.status_code  =  200 (200)
			✘ attr:tracetest.span.duration  <  500ms (1s) (https://app.tracetest.io/organizations/xxx/environments/xxx/test/W656Q0c4g/run/1/test?selectedAssertion=0&selectedSpan=94880e7cd465bd33)

	✘ Required gates
		✘ test-specs
```

## View Trace Spans Over Time in Honeycomb

To access a historical overview of all the trace spans the Node.js app generates, jump over to your Honeycomb account. With Honeycomb and Tracetest, you get the best of both worlds. You can run trace-based tests and automate running E2E and integration tests against real trace data. And, use Honeycomb to get a historical overview of all traces your distributed application generates.

![honeycomb](https://res.cloudinary.com/djwdcmwdz/image/upload/v1683813827/Blogposts/tracetest-honeycomb/screely-1683813821587_jxe64c.png)

## Learn More

Feel free to check out our [examples in GitHub](https://github.com/kubeshop/tracetest/tree/main/examples) and join our [Slack Community](https://dub.sh/tracetest-community) for more info!
